package cc.vv.btpartyjob.partymanager.activity

import android.view.WindowManager
import cc.vv.baselibrary.bean.base.BaseResponseObj
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.jnimodule.server.OperationServer
import cc.vv.btpartyjob.partymanager.delegate.ManagerBaseBinder
import cc.vv.btpartyjob.partymanager.delegate.WorkQingKuangDetailActivityDelegate
import cc.vv.btpartyjob.partymanager.inter.LookBigPicFileInterface
import cc.vv.btpartyjob.partymanager.moudel.resp.GetWorkDetailInfoResponseObj
import cc.vv.btpartyjob.partymanager.server.PartyManagerServer
import cc.vv.mvp.activity.BaseActivityMVP
import cc.vv.mvp.binder.BaseDataBinder
import com.dawning.utiming.task.server.SubmitJobServer

/**
 * 工作情况详情
 * Created by Chen.qi on 2018/10/27.
 */
class WorkQingKuangDetailActivity : BaseActivityMVP<WorkQingKuangDetailActivityDelegate>()
        , LookBigPicFileInterface {

    private var picList: ArrayList<String>? = null

    override fun initData() {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
        viewDelegate?.setTopBarTitle("工作详情")
        picList = ArrayList()
        val id = intent.getStringExtra("id")
        PartyManagerServer.getWorkingInfoDetail(id)

    }

    override fun bindEvenListener() {
        viewDelegate?.setTitleBackBtnOnClick(object : BaseTopBarView.EventInterface {
            //返回
            override fun leftOnClick() {
                finish()
            }

            override fun leftCloseClick() {}
            override fun rightOnClick() {
            }


        })


    }


    override fun getDelegateClass(): Class<WorkQingKuangDetailActivityDelegate> {
        return WorkQingKuangDetailActivityDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return ManagerBaseBinder()
    }


    override fun getData(obj: BaseResponseObj<*>?) {
        super.getData(obj)
        when (obj) {
            is GetWorkDetailInfoResponseObj -> {
                val data = obj.data
                viewDelegate?.setTime(OperationServer.formatStr(data?.createTime))
                viewDelegate?.setTitle(data?.title)
                viewDelegate?.setContent(data?.content)

                picList!!.clear()
                if (null != data.imgList) {
                    picList!!.addAll(data?.imgList!!)
                }
                viewDelegate?.onlyShowQianDao(this, picList)


            }
        }
    }

    override fun lookBigImage(position: Int, type: Int) {
        SubmitJobServer.largePic(this, picList!!, position)
    }


}